#include "mystdio.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
    const char* filename = "log.txt";
    myFILE* fp = my_fopen(filename, "w");
    if (fp == NULL)
    {
        perror("my_fopen");
        exit(-1);
    }
    const char* s = "123456789";
    int cnt = 9;
    char buffer[1024] = {0};
    while (cnt)
    {
        sprintf(buffer, "%s->%d\n", s, cnt);
        my_fwrite(fp, buffer, strlen(buffer));
        my_fflush(fp);
        cnt--;
        sleep(1);
    }
    
    my_fclose(fp);

    return 0;
}
